package com.flower.salary.controller;

import com.flower.salary.common.utils.R;
import com.flower.salary.domain.entity.SysSalary;
import com.flower.salary.domain.entity.SysUserSalary;
import com.flower.salary.domain.vo.UserInfoVO;
import com.flower.salary.service.SysSalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-02-12 20:53
 * 薪水发放
 */
@RequestMapping("/salary")
@RestController
public class SysSalaryController {

    @Autowired
    private SysSalaryService service;


    @GetMapping("/all")
    public R AllUserSalary(){

        List<SysUserSalary> all = service.getAll();
        return R.ok(all);
    }



    @PostMapping("/updateSalary")
    public R update(@RequestBody SysUserSalary body){
        int update = service.update(body);
        return R.ok("修改成功");
    }


    @PostMapping("/create")
    public R create(@RequestBody SysUserSalary body){
        service.create(body);
        return R.ok("创建工资单成功");
    }

    @GetMapping("/info")
    public R salaryInfo(String token){

        List<SysSalary> user = service.getUser(token);

        return R.ok(user);
    }

}
